/**
 * 导航列表
 * */
import React from 'react';
import {Link, withRouter} from 'react-router-dom'
import { Menu } from 'antd';
import './Nav.less';
import {updateMoudelInfoActiveName} from "./Redux";
import {
    createFromIconfontCN,
} from '@ant-design/icons';
const IconFont = createFromIconfontCN({
    scriptUrl: '//at.alicdn.com/t/font_1692529_ybt11z5boxo.js'
})
const { SubMenu } = Menu;
class Nav extends React.Component{
    constructor(props){
        super(props);
    }

    getKeys = () => {
        const { location = {} } = this.props;
        const { pathname = "" } = location;
        let selectedKeys = "1";
        let openKeys = 'sub1';
        if( pathname.indexOf("/login") > -1){selectedKeys = '1';}
        else if(pathname.indexOf("/home") > -1){selectedKeys = '2';}
        else if(pathname.indexOf("/myStoreList") > -1){selectedKeys = '3';}
        else if(pathname.indexOf("/verify") > -1){selectedKeys = '4';}

        return { selectedKeys, openKeys }
    }
    render(){
        const { selectedKeys, openKeys } = this.getKeys();
        return (
                <Menu
                    selectedKeys={[selectedKeys]}
                    defaultOpenKeys={[openKeys]}
                    mode="inline"
                    theme="dark"
                >
                    {/*<SubMenu*/}
                    {/*    key="sub1"*/}
                    {/*    title={*/}
                    {/*        <span>*/}
                    {/*            <IconFont type="icon-changguan"/>*/}
                    {/*            <span>小众点评</span>*/}
                    {/*          </span>*/}
                    {/*}>*/}
                    <Menu.Item key="1"><Link to="/login">登录</Link></Menu.Item>
                    <Menu.Item key="2"><Link to="/home">首页</Link></Menu.Item>
                    <Menu.Item key="3"><Link to="/myStoreList">我的店铺</Link></Menu.Item>
                    <Menu.Item key="4"><Link to="/verify">店铺审核</Link></Menu.Item>

                    {/*</SubMenu>*/}
                </Menu>
            )
        }

};
export default withRouter( Nav );
